#include <iostream>

#include "GradeSummary.h"

using namespace std;

int main()
  {
  wstring fname;
  wcin >> fname;


  try
    {
    GradeSummary gs(fname);

    double average = gs.GetAverage();

    wcout << endl << endl;
    wcout << "Average: " << average << endl;
    }
  catch(const GradeSummary::FileAccessError& err)
    {
    wcout << "No file exists or failed to opened" << endl;
    }
  catch(const GradeSummary::FileFormatError& err)
    {
    wcout << "File format error." << endl;
    wcout << "Line: " << err.m_nline;
    }
  catch(const GradeSummary::GrageOutOfRangeError& err)
    {
    wcout << "Grade out of range." << endl;
    wcout << "Line: " << err.m_nline;
    }
  catch(const GradeSummary::SubjectTwice& err)
    {
    wcout << "Subject defined twice" << endl;
    wcout << "Line: " << err.m_nline;
    }
  cout << endl;
  system("pause");
  return 0;
  }